﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GroupManager.Resource.CSDL;
using GroupManager.Class;
namespace GroupManager
{
    public partial class ThongTinDoi : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string mdoinhom = Request.QueryString["doinhom"];
            int madoinhom = int.Parse(mdoinhom);
            Literal1.Text = LopDoiNhom.LayThongTinNhom(madoinhom);

        }
        void Hien(bool An)
        {
            btHoanTat.Visible = An;
            btThoi.Visible = An;
            btSua.Visible = !An;
            Literal1.Visible = !An;
            CKEditorControl1.Visible = An;
        }
        protected void btSua_Click(object sender, EventArgs e)
        {
            Hien(true);
            CKEditorControl1.Text = Literal1.Text;
        }

        protected void btHoanTat_Click(object sender, EventArgs e)
        {
            string thongtin = CKEditorControl1.Text;
            if (string.IsNullOrEmpty(Server.HtmlEncode(thongtin)))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Thông tin nhóm rỗng!');", true);
                return;
            }
            string mdoinhom = Request.QueryString["doinhom"];
            int madoinhom = int.Parse(mdoinhom);
            Literal1.Text = thongtin;
            LopDoiNhom.SuaThongTinNhom(madoinhom, thongtin);
            Hien(false);
        }

        protected void btThoi_Click(object sender, EventArgs e)
        {
            Hien(false);
        }
    }
}